package thread;

import java.util.ArrayList;

public class Test {
    public  static void main(String[] args) throws InterruptedException {
        ArrayList<Integer> list =  new ArrayList<>();
        Thread t1 = new Thread(){
          public void run(){
              for (int i = 0; i < 100; i++) {
                  synchronized (Test.class){
                      list.add(i);
                  }
              }
          }
        };
        Thread t2 = new Thread(){
          public void run(){
              for (int i = 0; i < 100; i++) {
                  synchronized (Test.class){
                      list.add(i);
                  }
              }
          }
        };
        t1.start();
        t2.start();

        Thread.sleep(1000);
        System.out.println(list.size());
//        synchronized (Test.class){
//            list.add(i)
//        }
    }
}


class Coo{
    public synchronized void aa(){


    }
    public synchronized void bb(){


    }
}






